/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  router.post('/api/user/login', controller.user.login);
  router.get('/api/user/info', controller.user.info);
  router.get('/api/user/menu', controller.user.menu);
  router.post('/api/business/create', controller.user.register);

  // 菜单管理
  router.get('/api/menu/list', controller.menu.list);
  router.post('/api/menu', controller.menu.create);
  router.delete('/api/menu/:id', controller.menu.delete);
  router.put('/api/menu/:id', controller.menu.update);
  router.get('/api/menu/:id', controller.menu.show);

  // 角色管理
  router.post('/api/role', controller.role.create);
  router.get('/api/role', controller.role.list);
  router.delete('/api/role/:id', controller.role.delete);
  router.put('/api/role/:id', controller.role.update);
  router.get('/api/role/:id', controller.role.show);

  // 字典管理
  router.post('/api/dict/type', controller.dict.type.create);
  router.get('/api/dict/type', controller.dict.type.list);
  router.get('/api/dict/type/:id', controller.dict.type.show);
  router.delete('/api/dict/type/:id', controller.dict.type.delete);
  router.put('/api/dict/type/:id', controller.dict.type.update);

  router.get('/api/dict/:type', controller.dict.data.list);
  router.post('/api/dict/:type', controller.dict.data.create);
  router.get('/api/dict/:type/:id', controller.dict.data.show);
  router.delete('/api/dict/:type/:id', controller.dict.data.delete);
  router.put('/api/dict/:type/:id', controller.dict.data.update);

  // 服务管理
  router.get('/api/serve/list', controller.serve.list);
  router.post('/api/serve', controller.serve.create);
  router.put('/api/serve/:id', controller.serve.update);
  router.delete('/api/serve/:id', controller.serve.delete);
  router.post('/api/serve/deleteAll', controller.serve.delete);

  // 员工管理
  router.get('/api/personnel', controller.user.list);
  router.get('/api/personnel/:id', controller.user.show);
  router.post('/api/personnel', controller.user.create);
  router.put('/api/personnel/:id', controller.user.update);
  router.delete('/api/personnel/:id', controller.user.delete);
  router.delete('/api/personnel', controller.user.delete);


  router.get('/api/shop/products', controller.shop.product.list);

  router.post('/api/upload', controller.base.upload);

  router.get('*', controller.home.render);
};
